n = int(input())
dict1 = dict()
for i in range(n):
    name, score = input().split()
    dict1[int(score)] = name
keys = list(dict1)
avg = sum(keys) / n / 2
key2 = list(map(lambda x: abs(x - avg), keys))
min = key2[0]
index = 0
for i, x in enumerate(key2):
    if (x < min):
        index = i
        min = x
print(int(avg),dict1[keys[index]])
